<?php
class ReplyMessageForm extends Zend_Form {
	
	private $thread;
	
	public function ReplyMessageForm($thread) {
		$this->thread = $thread;
		$this->__construct();
	}
	
	public function init() {
		$this->setMethod("POST");
        $this->setName("ReplyMSG");
        
        $element = new Zend_Form_Element_Hidden("targetUserId");
        $element->removeDecorator('Label');
        $element->setValue($this->targetUserId);
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Hidden("tid");
        $element->setValue($this->thread->thread_id);
        $element->removeDecorator('Label');
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Hidden("messageType");
        $userMessages = MessageThread::findByThread($this->thread->thread_id);
        $userMessageId = $userMessages[0]["user_message_id"];
        $table = new UserMessage();
        $userMessage = $table->findById($userMessageId);
        $message = UserMessage::getMessage($userMessage);
        $element->setValue($message->type);
        $element->removeDecorator('Label');
        $this->addElement($element);
               
		$this->addDisplayGroup(array('targetUserId', 'messageType','messageId'),'hiddenMSGInfo')->removeDecorator('Label');;
        
        $element = new Zend_Form_Element_Textarea("message");
        $element->setLabel("Reply");
        $element->setAttrib('rows',4);
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Submit("send");
        $element->removeDecorator('Label');
        $this->addElement($element);
	}
}
?>